﻿Public Class frmReconnaConstrue
    Private m_reconnaissance As New ReconnaissanceDataConcourse

    '做比较的 四个干球温度变量
    Private m_Tem1 As Double = 0
    Private m_Tem2 As Double = 0
    Private m_Tem3 As Double = 0
    Private m_Tem4 As Double = 0

    Private m_H1 As Double = 0
    Private m_H2 As Double = 0
    Private m_H3 As Double = 0
    Private m_H4 As Double = 0
    Private m_Select As Integer = 0
    Private m_SelectTime As Integer = 0
    '用于保存全年的 逆温次数，平均高度，强度，频率数组
    Private m_SumCount() As Integer = {0, 0, 0}
    Private m_SumHeitht() As Double = {0, 0, 0}
    Private m_SumIntensity() As Double = {0, 0, 0}
    Private m_SumFrequency() As Double = {0, 0, 0}
    Private m_OverallCount() As Integer = {0, 0, 0}
    '日期的变量
    Private m_Date As String = ""
    '时间的变量
    Private m_Time As String = ""
    '索引
    Private m_index As Integer = 0
    Private b As Integer = 0

    Private m_ArrReconnArrayDataType(-1) As ReconnArrayDataType

    Property ReconnaissanceDataConcourse() As ReconnaissanceDataConcourse
        Get
            Return Me.m_reconnaissance
        End Get
        Set(ByVal value As ReconnaissanceDataConcourse)
            Me.m_reconnaissance = value
        End Set
    End Property
    ''' <summary>
    ''' 创建数组数据 一共16个元素（索引 0 - 3 是季度，索引 4-15 是 1 - 12 月份）
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub CreateArrayData()

        For i As Integer = 0 To 16 - 1
            ReDim Preserve Me.m_ArrReconnArrayDataType(Me.m_ArrReconnArrayDataType.Length)
            Me.m_ArrReconnArrayDataType(Me.m_ArrReconnArrayDataType.Length - 1) = New ReconnArrayDataType
        Next
    End Sub
    ''' <summary>
    ''' 窗体的加载事件 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub frmReconnaConstrue_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.EFlexDataShow.Styles.Alternate.BackColor = Color.FromArgb(216, 228, 248)


        If StringHandle.m_openFile = 1 Then
            Me.cob_SumType.Text = "月变化"
            Me.cob_TimeType.Text = "上午"
            Me.cob_ParameterType.Text = "频率"

            '创建长度为17个的对象数组，0 - 3表示4季，4 - 15 表示 1-12月份
            CreateArrayData()

            '分析处理数据
            ArrDtaManage()

            '表中显示数据并画出曲线图
            ShowEflexAndTchartData()

        End If

        Me.EFlexDataShow.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
        Me.EFlexDataShow.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.None
        Me.EFlexDataShow.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
    End Sub
    ''' <summary>
    ''' 得到 出现逆温时 的两个不为默认值的干球温度
    ''' </summary>
    ''' <param name="i"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function AthwartTemperature(ByVal newData As String, ByVal i As Integer, ByVal j As Integer, ByVal h As Integer) As Double
        '
        Dim b As Integer = 0
        '温度差
        Dim Difference As Double = 0
        Me.m_Tem1 = 0
        Me.m_Tem2 = 0
        Me.m_Tem3 = 0
        Me.m_Tem4 = 0
        Me.m_H1 = 0
        Me.m_H2 = 0
        Me.m_H3 = 0
        Me.m_H4 = 0
       
        For p As Integer = 0 To Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData.Length - 1
            '得到做比较的第二个温度
            If b = 1 And Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature <> -9990 Then

                m_Tem2 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature
                Me.m_H2 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DistanceTerraHeight

                If m_Tem1 < m_Tem2 Then
                    b = 2
                Else
                    b = 0
                End If
            End If

            '得到做比较的第一个温度
            If b = 0 And Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature <> -9990 Then
                m_Tem1 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature
                Me.m_H1 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DistanceTerraHeight
                b = 1
            End If

            '得到做比较的第四个温度
            '如果 Me.m_Tem3 > Me.m_Tem4 说明 逆温到 Me.m_Tem3 停止了，  Me.m_Tem4 开始降温了
            If b = 3 And Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature <> -9990 Then
                Me.m_Tem4 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature
                Me.m_H4 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DistanceTerraHeight

                If Me.m_Tem3 > Me.m_Tem4 Then
                    Me.m_ArrReconnArrayDataType(j).ArrDataType(h).MyArrDataConstrue(0).MyHeitht += Me.m_H1 'Me.m_H3
                    '逆温层的温度差
                    Difference = Me.m_Tem3 - Me.m_Tem1
                 
                    Me.m_ArrReconnArrayDataType(j).ArrDataType(h).MyArrDataConstrue(0).MyIntensity += System.Math.Abs(Difference) / (Me.m_H3 - Me.m_H1)

                    '''''''''''''
                    Me.m_ArrReconnArrayDataType(j).ArrDataType(2).MyArrDataConstrue(0).MyHeitht += Me.m_H1 'Me.m_H3
                    Me.m_ArrReconnArrayDataType(j).ArrDataType(2).MyArrDataConstrue(0).MyIntensity += System.Math.Abs(Difference) / (Me.m_H3 - Me.m_H1)
                    ''''''''''''''''

                    If Me.m_Select = 0 Then
                        '得到全年数据，上午的高度和，强度和
                        If Me.m_SelectTime = 0 Then
                            Me.m_SumHeitht(0) += Me.m_H1 'Me.m_H3
                            Me.m_SumIntensity(0) += System.Math.Abs(Difference) / (Me.m_H3 - Me.m_H1)
                            '得到全年数据，下午的高度和，强度和
                        ElseIf Me.m_SelectTime = 1 Then
                            Me.m_SumHeitht(1) += Me.m_H1 'Me.m_H3
                            Me.m_SumIntensity(1) += System.Math.Abs(Difference) / (Me.m_H3 - Me.m_H1)
                        Else
                            'Me.m_SumHeitht(2) += Me.m_H1 'Me.m_H3
                            'Me.m_SumIntensity(2) += System.Math.Abs(Difference) / (Me.m_H3 - Me.m_H1)

                        End If
                        '得到全年数据，全天的高度和，强度和
                        Me.m_SumHeitht(2) += Me.m_H1 'Me.m_H3
                        Me.m_SumIntensity(2) += System.Math.Abs(Difference) / (Me.m_H3 - Me.m_H1) 'Me.m_ArrReconnArrayDataType(j).ArrDataType(h).MyArrDataConstrue(0).MyIntensity
                    End If

                    GetDataType(newData, j, h)
                    Exit Function
                Else
                    b = 2
                End If
            End If

            '得到比较的第三个温度，表示出现逆温的 最高温度
            If b = 2 And Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature <> -9990 Then
                m_Tem3 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DryTemperature
                Me.m_H3 = Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData(p).DistanceTerraHeight
                b = 3
            End If
        Next

    End Function
    ''' <summary>
    ''' 判断是上午还是下午的数据
    ''' </summary>
    ''' <param name="newData">日期 + 时间</param>
    ''' <param name="i">数组的索引</param>
    ''' <param name="j">数组的索引 0 - 3 四季，4 - 15 表示 1 - 12 月份 </param>
    ''' <param name="index"></param>
    ''' <remarks></remarks>
    Private Sub SelectDataType(ByVal newData As String, ByVal i As Integer, ByVal j As Integer, ByVal index As Integer)
        If Me.m_reconnaissance.ArrReconnaissance(i).Time > -1 And Me.m_reconnaissance.ArrReconnaissance(i).Time < 13 Then
            Me.m_ArrReconnArrayDataType(j).ArrDataType(0).Sum += 1

        Else
            Me.m_ArrReconnArrayDataType(j).ArrDataType(1).Sum += 1

        End If
        Me.m_ArrReconnArrayDataType(j).ArrDataType(2).Sum += 1

        If Me.m_reconnaissance.ArrReconnaissance(i).ArrtierData.Length > 2 Then


            '上午
            If Me.m_reconnaissance.ArrReconnaissance(i).Time > -1 And Me.m_reconnaissance.ArrReconnaissance(i).Time < 13 Then

                ' 得到 出现逆温时 的两个不为默认值的干球温度
                Me.m_SelectTime = 0
                AthwartTemperature(newData, i, j, 0)


            Else
                ' 下午
                ' 得到 出现逆温时 的两个不为默认值的干球温度
                Me.m_SelectTime = 1
                AthwartTemperature(newData, i, j, 1)


            End If

            '取消了得到全天的算法
            '全天
            ' 得到 出现逆温时 的两个不为默认值的干球温度
            'Me.m_SelectTime = 2
            ' AthwartTemperature(newData, i, j, 1)
            '' m_Select = 1
           

        End If
    End Sub
    ''' <summary>
    ''' 得到数据后，具体分析
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ArrDtaManage()
        
        Dim newData As String = ""
        Dim oldData As String = ""

        If Me.m_reconnaissance.ArrReconnaissance.Length > 2 Then
            For i As Integer = 0 To Me.m_reconnaissance.ArrReconnaissance.Length - 1

                If i > 0 Then
                    oldData = Me.m_reconnaissance.ArrReconnaissance(i - 1).Year & Me.m_reconnaissance.ArrReconnaissance(i - 1).Month & Me.m_reconnaissance.ArrReconnaissance(i - 1).Day
                    newData = Me.m_reconnaissance.ArrReconnaissance(i).Year & Me.m_reconnaissance.ArrReconnaissance(i).Month & Me.m_reconnaissance.ArrReconnaissance(i).Day

                End If

                '如果是四季时
                Me.m_Select = 0
                If Me.m_reconnaissance.ArrReconnaissance(i).Month = "03" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "04" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "05" Then
                    SelectDataType(newData, i, 0, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "06" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "07" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "08" Then
                    SelectDataType(newData, i, 1, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "09" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "10" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "11" Then
                    SelectDataType(newData, i, 2, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "12" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "01" Or Me.m_reconnaissance.ArrReconnaissance(i).Month = "02" Then
                    SelectDataType(newData, i, 3, 0)
                End If

                '如果是 1 - 12 月份时
                Me.m_Select = 1
                If Me.m_reconnaissance.ArrReconnaissance(i).Month = "01" Then
                    SelectDataType(newData, i, 4, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "02" Then
                    SelectDataType(newData, i, 5, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "03" Then
                    SelectDataType(newData, i, 6, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "04" Then
                    SelectDataType(newData, i, 7, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "05" Then
                    SelectDataType(newData, i, 8, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "06" Then
                    SelectDataType(newData, i, 9, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "07" Then
                    SelectDataType(newData, i, 10, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "08" Then
                    SelectDataType(newData, i, 11, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "09" Then
                    SelectDataType(newData, i, 12, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "10" Then
                    SelectDataType(newData, i, 13, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "11" Then
                    SelectDataType(newData, i, 14, 0)
                ElseIf Me.m_reconnaissance.ArrReconnaissance(i).Month = "12" Then
                    SelectDataType(newData, i, 15, 0)

                End If
            Next
        End If

        '上面算法取消了得到全天数据的循环
        '全天数据数组，用上午数组的长度加上下午的数组的长度
        '也就是全天出现的逆温次数
        For i As Integer = 0 To Me.m_ArrReconnArrayDataType.Length - 1
            Me.m_ArrReconnArrayDataType(i).ArrDataType(2).ArrayL = Me.m_ArrReconnArrayDataType(i).ArrDataType(0).ArrayL + Me.m_ArrReconnArrayDataType(i).ArrDataType(1).ArrayL
        Next
       
        '  下边是得到 频率（逆温次数/测试次数）,高度平均值( 出现逆温时的高度 / 出现逆温的次数) , 强度 （强度 = 温度差 / 高度差）
        For i As Integer = 0 To Me.m_ArrReconnArrayDataType.Length - 1
            If i = 4 Then
                Dim a As Integer = 0
            End If
            For j As Integer = 0 To 2

                If i < 4 Then
                    m_SumCount(j) += Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL 'MyArrDateCount.Length
                    m_OverallCount(j) += Me.m_ArrReconnArrayDataType(i).ArrDataType(j).Sum
                End If


                '下边是得到 频率
                If Me.m_ArrReconnArrayDataType(i).ArrDataType(j).Sum <> 0 Then
                    Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyFrequency = Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL / Me.m_ArrReconnArrayDataType(i).ArrDataType(j).Sum ' Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length / Me.m_ArrReconnArrayDataType(i).ArrDataType(j).Sum
                    Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyFrequency = Mid(Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyFrequency, 1, 6)
                Else
                    Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyFrequency = 0
                End If
              
                '下边是得到(高度的平均值)
                If Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL Then  ' Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length <> 0 Then
                    Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyHeitht = Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyHeitht / Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL ' Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length
                    Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyHeitht = Mid(Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyHeitht, 1, 5)

                Else
                    Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyHeitht = 0
                End If
               
                '强度 （强度 = 温度差/高度差）
                If Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyIntensity = 0 Then
                    Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyIntensity = 0
                Else
                    If Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL = 0 Then
                        Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyIntensity = 0
                    Else
                        Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyIntensity = Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyIntensity / Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL
                        Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyIntensity = Mid(Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDataConstrue(0).MyIntensity, 1, 5)

                    End If


                End If
            Next
        Next

        '全年数据的频率，平均高度，强度
        For i As Integer = 0 To 2
            If m_SumCount(i) <> 0 Then

                Me.m_SumFrequency(i) = Me.m_SumCount(i) / Me.m_OverallCount(i) ' Me.m_reconnaissance.ArrReconnaissance.Length
                Me.m_SumFrequency(i) = Mid(Me.m_SumFrequency(i).ToString, 1, 5)
                Me.m_SumHeitht(i) = Me.m_SumHeitht(i) / m_SumCount(i)
                Me.m_SumHeitht(i) = Mid(Me.m_SumHeitht(i).ToString, 1, 5)
                Me.m_SumIntensity(i) = Me.m_SumIntensity(i) / m_SumCount(i)
                Me.m_SumIntensity(i) = Mid(Me.m_SumIntensity(i).ToString, 1, 5)
            Else
                Me.m_SumFrequency(i) = 0
                Me.m_SumHeitht(i) = 0
                Me.m_SumIntensity(i) = 0


            End If
        Next
    End Sub
    ''' <summary>
    ''' 得到对应 出现逆温的日期，也得到对应出现逆温的次数
    ''' </summary>
    ''' <param name="newData"> 日期</param>
    ''' <param name="i"> 是季度 还是月份，一共16个元素 0-3 是四季，4-15 是12个月份</param>
    ''' <param name="j">上午是0，下午是1 ，全天是2</param>
    ''' <remarks></remarks>
    Private Sub GetDataType(ByVal newData As String, ByVal i As Integer, ByVal j As Integer)
        Me.m_ArrReconnArrayDataType(i).ArrDataType(j).Agency = 0
      
        If j <> 2 Then
            If Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL > 0 Then
                For p As Integer = 0 To Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length - 1

                    If newData = Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount(p).MyDate Then
                        Me.m_ArrReconnArrayDataType(i).ArrDataType(j).Agency = 1
                    End If
                Next
            End If
        End If

        If Me.m_ArrReconnArrayDataType(i).ArrDataType(j).Agency = 0 Then

            ReDim Preserve Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount(Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length)
            Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount(Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length - 1) = New ReconnDateCount
            Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount(Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length - 1).MyDate = newData
            Me.m_ArrReconnArrayDataType(i).ArrDataType(j).ArrayL = Me.m_ArrReconnArrayDataType(i).ArrDataType(j).MyArrDateCount.Length
           
        End If
    End Sub
    
    ''' <summary>
    ''' 在表格中显示数据，并画出曲线图
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ShowEflexAndTchartData()

        Dim i As Integer = 0
        Dim j As Integer = 0
        Dim p As Integer = 0



        If Me.cob_SumType.Text = "季度变化" Then
            i = 0
        ElseIf Me.cob_SumType.Text = "月变化" Then
            i = 1
        Else
            i = 2

        End If


        If Me.cob_TimeType.Text = "上午" Then
            j = 0
        ElseIf Me.cob_TimeType.Text = "下午" Then

            j = 1
        Else
            j = 2
        End If


        If Me.cob_ParameterType.Text = "频率" Then
            p = 0
        ElseIf Me.cob_ParameterType.Text = "平均高度" Then
            p = 1
        Else
            p = 2
        End If
        SetCob_DataType(i, j, p)

    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="i">下拉框是 -月变化，季度变化，日变化</param>
    ''' <param name="j">下拉框是 -上午，下午，全天</param>
    ''' <param name="p">下拉框是 -频率，强度，平均高度</param>
    ''' <remarks></remarks>
    Private Sub SetCob_DataType(ByVal i As Integer, ByVal j As Integer, ByVal p As Integer)
        Me.EFlexDataShow.SetData(0, 0, "类别")
        Me.EFlexDataShow.Rows.Count = 2


        If p = 0 Then
            Me.EFlexDataShow.SetData(1, 0, "频率")
        ElseIf p = 1 Then
            Me.EFlexDataShow.SetData(1, 0, "平均高度")
        Else
            Me.EFlexDataShow.SetData(1, 0, "强度")
        End If


        If i = 0 Then

            Me.EFlexDataShow.Cols.Count = 6

            Me.EFlexDataShow.SetData(0, 1, "春季")
            Me.EFlexDataShow.SetData(0, 2, "夏季")
            Me.EFlexDataShow.SetData(0, 3, "秋季")
            Me.EFlexDataShow.SetData(0, 4, "冬季")
            Me.EFlexDataShow.SetData(0, 5, "全年")

            If j = 0 Then
                SetEflexAndTchart(0, 0, p)

            ElseIf j = 1 Then
                SetEflexAndTchart(0, 1, p)

            Else
                SetEflexAndTchart(0, 2, p)

            End If

        ElseIf i = 1 Then

            Me.EFlexDataShow.Cols.Count = 14

            Me.EFlexDataShow.SetData(0, 1, "1月")
            Me.EFlexDataShow.SetData(0, 2, "2月")
            Me.EFlexDataShow.SetData(0, 3, "3月")
            Me.EFlexDataShow.SetData(0, 4, "4月")
            Me.EFlexDataShow.SetData(0, 5, "5月")
            Me.EFlexDataShow.SetData(0, 6, "6月")
            Me.EFlexDataShow.SetData(0, 7, "7月")
            Me.EFlexDataShow.SetData(0, 8, "8月")
            Me.EFlexDataShow.SetData(0, 9, "9月")
            Me.EFlexDataShow.SetData(0, 10, "10月")
            Me.EFlexDataShow.SetData(0, 11, "11月")
            Me.EFlexDataShow.SetData(0, 12, "12月")
            Me.EFlexDataShow.SetData(0, 13, "全年")

            If j = 0 Then
                SetEflexAndTchart(1, 0, p)

            ElseIf j = 1 Then
                SetEflexAndTchart(1, 1, p)

            Else
                SetEflexAndTchart(1, 2, p)

            End If

        Else
            ' CobChange()
            SetEflexAndTchart(2, 0, p)
        End If

    End Sub
 
    ''' <summary>
    ''' 设置显示表格中的数据，并画出曲线图
    ''' </summary>
    ''' <param name="i">季度还是月份</param>
    ''' <param name="j">上午，下午，全天</param>
    ''' <param name="p">频率，强度，平均高度</param>
    ''' <remarks></remarks>
    Private Sub SetEflexAndTchart(ByVal i As Integer, ByVal j As Integer, ByVal p As Integer)
        Dim Intensity As Double = 0

        Me.TChart1.Aspect.View3D = False
        Me.TChart1.Series.Clear()
        Dim ser1 As New Steema.TeeChart.Styles.Line
        If j = 0 Then
            If p = 0 Then
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumFrequency(0))
            ElseIf p = 1 Then
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumHeitht(0))
            Else
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumIntensity(0))
            End If
        ElseIf j = 1 Then
            If p = 0 Then
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumFrequency(1))
            ElseIf p = 1 Then
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumHeitht(1))
            Else
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumIntensity(1))
            End If
        Else
            If p = 0 Then
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumFrequency(2))
            ElseIf p = 1 Then
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumHeitht(2))
            Else
                Me.EFlexDataShow.SetData(1, Me.EFlexDataShow.Cols.Count - 1, Me.m_SumIntensity(2))
            End If
        End If

        '选择 0 = 季度，1 = 月份
        If i = 0 Then

            If p = 0 Then
                For t As Integer = 0 To 4 - 1

                    Me.EFlexDataShow.SetData(1, t + 1, Me.m_ArrReconnArrayDataType(t).ArrDataType(j).MyArrDataConstrue(0).MyFrequency)
                    ser1.Add(t + 1, Me.m_ArrReconnArrayDataType(t).ArrDataType(j).MyArrDataConstrue(0).MyFrequency)
                Next
                Me.TChart1.Text = "季度逆温差频率变化曲线图"
                ''设置左坐标
                Me.TChart1.Axes.Left.Automatic = False
                Me.TChart1.Axes.Left.Minimum = 0.01
                Me.TChart1.Axes.Left.Maximum = 1
                '设置底坐标
                Me.TChart1.Axes.Bottom.Automatic = False
                Me.TChart1.Axes.Bottom.Minimum = 1
                Me.TChart1.Axes.Bottom.Maximum = 4
            ElseIf p = 1 Then

                For t As Integer = 0 To 4 - 1
                    Me.EFlexDataShow.SetData(1, t + 1, Me.m_ArrReconnArrayDataType(t).ArrDataType(j).MyArrDataConstrue(0).MyHeitht)
                    ser1.Add(t + 1, Me.m_ArrReconnArrayDataType(t).ArrDataType(j).MyArrDataConstrue(0).MyHeitht)
                Next
                Me.TChart1.Text = "季度逆温差平均高度变化变化曲线图"
                ''设置左坐标
                Me.TChart1.Axes.Left.Automatic = False
                Me.TChart1.Axes.Left.Minimum = 0
                Me.TChart1.Axes.Left.Maximum = 1500
                '设置底坐标
                Me.TChart1.Axes.Bottom.Automatic = False
                Me.TChart1.Axes.Bottom.Minimum = 1
                Me.TChart1.Axes.Bottom.Maximum = 4
            Else
                For t As Integer = 0 To 4 - 1
                    Me.EFlexDataShow.SetData(1, t + 1, Me.m_ArrReconnArrayDataType(t).ArrDataType(j).MyArrDataConstrue(0).MyIntensity)
                    ser1.Add(t + 1, Me.m_ArrReconnArrayDataType(t).ArrDataType(j).MyArrDataConstrue(0).MyIntensity)
                Next
                Me.TChart1.Text = "季度逆温差的强度变化曲线图"
                ''设置左坐标
                Me.TChart1.Axes.Left.Automatic = False
                Me.TChart1.Axes.Left.Minimum = 0.001
                Me.TChart1.Axes.Left.Maximum = 0.1
                '设置底坐标
                Me.TChart1.Axes.Bottom.Automatic = False
                Me.TChart1.Axes.Bottom.Minimum = 1
                Me.TChart1.Axes.Bottom.Maximum = 4
            End If

        ElseIf i = 1 Then

            If p = 0 Then
                For t As Integer = 0 To 12 - 1
                    Me.EFlexDataShow.SetData(1, t + 1, Me.m_ArrReconnArrayDataType(t + 4).ArrDataType(j).MyArrDataConstrue(0).MyFrequency)
                    ser1.Add(t + 1, Me.m_ArrReconnArrayDataType(t + 4).ArrDataType(j).MyArrDataConstrue(0).MyFrequency)
                Next
                Me.TChart1.Text = "月逆温差频率变化曲线图"
                ''设置左坐标
                Me.TChart1.Axes.Left.Automatic = False
                Me.TChart1.Axes.Left.Minimum = 0.01
                Me.TChart1.Axes.Left.Maximum = 1
                '设置底坐标
                Me.TChart1.Axes.Bottom.Automatic = False
                Me.TChart1.Axes.Bottom.Minimum = 1
                Me.TChart1.Axes.Bottom.Maximum = 12

            ElseIf p = 1 Then

                For t As Integer = 0 To 12 - 1
                    Me.EFlexDataShow.SetData(1, t + 1, Me.m_ArrReconnArrayDataType(t + 4).ArrDataType(j).MyArrDataConstrue(0).MyHeitht)
                    ser1.Add(t + 1, Me.m_ArrReconnArrayDataType(t + 4).ArrDataType(j).MyArrDataConstrue(0).MyHeitht)
                Next
                Me.TChart1.Text = "月逆温差平均高度变化曲线图"
                ''设置左坐标
                Me.TChart1.Axes.Left.Automatic = False
                Me.TChart1.Axes.Left.Minimum = 0
                Me.TChart1.Axes.Left.Maximum = 2000
                '设置底坐标
                Me.TChart1.Axes.Bottom.Automatic = False
                Me.TChart1.Axes.Bottom.Minimum = 1
                Me.TChart1.Axes.Bottom.Maximum = 12

            Else

                For t As Integer = 0 To 12 - 1
                    Me.EFlexDataShow.SetData(1, t + 1, Me.m_ArrReconnArrayDataType(t + 4).ArrDataType(j).MyArrDataConstrue(0).MyIntensity)
                    ser1.Add(t + 1, Me.m_ArrReconnArrayDataType(t + 4).ArrDataType(j).MyArrDataConstrue(0).MyIntensity)
                Next
                Me.TChart1.Text = "月逆温差强度变化曲线图"
                ''设置左坐标
                Me.TChart1.Axes.Left.Automatic = False
                Me.TChart1.Axes.Left.Minimum = 0.001
                Me.TChart1.Axes.Left.Maximum = 0.1
                '设置底坐标
                Me.TChart1.Axes.Bottom.Automatic = False
                Me.TChart1.Axes.Bottom.Minimum = 1
                Me.TChart1.Axes.Bottom.Maximum = 12

            End If
        Else
            
            ser1.Clear()
            For t As Integer = 0 To Me.m_reconnaissance.ArrReconnaissance(Me.m_index).ArrtierData.Length - 1
                If Me.m_reconnaissance.ArrReconnaissance(Me.m_index).ArrtierData(t).DryTemperature <> -9990 And Me.m_reconnaissance.ArrReconnaissance(Me.m_index).ArrtierData(t).DistanceTerraHeight <> -99999 Then
                    
                    ser1.Add(Me.m_reconnaissance.ArrReconnaissance(Me.m_index).ArrtierData(t).DryTemperature / 10, Me.m_reconnaissance.ArrReconnaissance(Me.m_index).ArrtierData(t).DistanceTerraHeight) '/ 10)
                End If
            Next
            Me.TChart1.Text = "日温度变化曲线图"
            ''  设置左坐标()
           

            Me.TChart1.Axes.Left.Automatic = False
            Me.TChart1.Axes.Left.Minimum = 0
            Me.TChart1.Axes.Left.Maximum = 5000
            '  Me.TChartTemperature.Axes.Left.Labels.
            '设置底坐标
            'Me.TChart1.Axes.Bottom.Inverted = True
            Me.TChart1.Axes.Bottom.Automatic = False
            'Me.TChart1.Axes.Bottom.AutomaticMaximum = True
            'Me.TChart1.Axes.Bottom.AutomaticMinimum = True
            Me.TChart1.Axes.Bottom.Minimum = -30
            Me.TChart1.Axes.Bottom.Maximum = 30


        End If

        Me.EFlexDataShow.AutoResize = True
        Me.EFlexDataShow.AutoSizeCols()
        Me.EFlexDataShow.AutoSizeRows()
        Me.EFlexDataShow.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
        Me.EFlexDataShow.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.None
        Me.EFlexDataShow.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.None
        Me.EFlexDataShow.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None

        Me.TChart1.Series.Add(ser1)
        '  Me.TChart1.Header.Text = "月逆温差高度变化曲线图"
        Me.TChart1.Header.Font.Color = Color.Black
        ' Me.TChart1.Export.Image.JPEG.CopyToClipboard()
        '   TChart1.ShowEditor()
        TChart1.Legend.Shadow.Visible = False
        TChart1.Panel.Gradient.Visible = True
        TChart1.Panel.Gradient.StartColor = Color.White      ' 图表底色开始颜色
        TChart1.Panel.Gradient.EndColor = Color.White     ' 图表底色结束颜色
        TChart1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series


        ' TChart1.Legend.CheckBoxes = True

    End Sub


   
    Private Sub cob_TimeType_SelectionChangeCommitted_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cob_TimeType.SelectionChangeCommitted
        '  Me.ShowEflexAndTchartData()
        '获得当前选择的日期
        m_Date = Me.cob_TimeType.Text + Me.cob_ParameterType.Text
        ' 获取选择的日期时间在 对象数组中 的索引
        CompareData()

        Me.ShowEflexAndTchartData()
    End Sub

    Private Sub cob_ParameterType_SelectionChangeCommitted_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cob_ParameterType.SelectionChangeCommitted   
        Me.ShowEflexAndTchartData()
        '获得当前选择的日期
        m_Date = Me.cob_TimeType.Text + Me.cob_ParameterType.Text
        ' 获取选择的日期时间在 对象数组中 的索引
        CompareData()
        Me.ShowEflexAndTchartData()
    End Sub
    ''' <summary>
    ''' 获取选择的日期时间在 对象数组中 的索引
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub CompareData()
        For i As Integer = 0 To Me.m_reconnaissance.ArrReconnaissance.Length - 1
            If (Me.m_reconnaissance.ArrReconnaissance(i).Year + Me.m_reconnaissance.ArrReconnaissance(i).Month + Me.m_reconnaissance.ArrReconnaissance(i).Day + Me.m_reconnaissance.ArrReconnaissance(i).Time) = m_Date Then '(m_Date + m_Time) Then
                m_index = i
                Exit Sub
            End If
        Next
    End Sub
    ''' <summary>
    ''' 看选择的时 日变化，季度变化 ，日变化
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub CobChange()

        If Me.cob_SumType.Text = "日温度变化" Then
            b = 1
            Me.cob_TimeType.Items.Clear()
            Me.cob_ParameterType.Items.Clear()

            'Me.cob_TimeType.Items.Add("08")
            'Me.cob_TimeType.Items.Add("20")
            'Me.cob_TimeType.Text = "08"
            ShowTime()

            Me.EFlexDataShow.Visible = False

        
        Else
            If b = 1 Then
                Me.cob_TimeType.Items.Clear()
                Me.cob_ParameterType.Items.Clear()
                Me.cob_TimeType.Items.Add("上午")
                Me.cob_TimeType.Items.Add("下午")
                Me.cob_TimeType.Items.Add("全天")
                Me.cob_TimeType.Text = "上午"

                Me.cob_ParameterType.Items.Add("频率")
                Me.cob_ParameterType.Items.Add("强度")
                Me.cob_ParameterType.Items.Add("平均高度")
                Me.cob_ParameterType.Text = "频率"

                Me.EFlexDataShow.Visible = True
                b = 0

            End If


        End If
    End Sub
    Private Sub cob_SumType_SelectionChangeCommitted_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cob_SumType.SelectionChangeCommitted
        Me.CobChange()
        Me.ShowEflexAndTchartData()
    End Sub
    ''' <summary>
    ''' 在窗体加载时把值 赋给 comboBox框 
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ShowTime()
        Dim s_oldYear As String = ""
        Dim s_newYear As String = ""
        Dim s_Count As Integer = 1

        For i As Integer = 0 To Me.m_reconnaissance.ArrReconnaissance.Length - 1
            s_oldYear = Me.m_reconnaissance.ArrReconnaissance(i).Year + Me.m_reconnaissance.ArrReconnaissance(i).Month + Me.m_reconnaissance.ArrReconnaissance(i).Day
            s_newYear = Me.m_reconnaissance.ArrReconnaissance(i + 1).Year + Me.m_reconnaissance.ArrReconnaissance(i + 1).Month + Me.m_reconnaissance.ArrReconnaissance(i + 1).Day

            If s_oldYear = s_newYear Then
                s_Count += 1
            Else
                Exit For
            End If
        Next
        For i As Integer = 0 To s_Count - 1

            Me.cob_ParameterType.Items.Add(Me.m_reconnaissance.ArrReconnaissance(i).Time)


        Next
        For i As Integer = 0 To Me.m_reconnaissance.ArrReconnaissance.Length - 2
            s_oldYear = Me.m_reconnaissance.ArrReconnaissance(i).Year + Me.m_reconnaissance.ArrReconnaissance(i).Month + Me.m_reconnaissance.ArrReconnaissance(i).Day
            s_newYear = Me.m_reconnaissance.ArrReconnaissance(i + 1).Year + Me.m_reconnaissance.ArrReconnaissance(i + 1).Month + Me.m_reconnaissance.ArrReconnaissance(i + 1).Day
            If s_oldYear <> s_newYear Then

                Me.cob_TimeType.Items.Add(Me.m_reconnaissance.ArrReconnaissance(i).Year + Me.m_reconnaissance.ArrReconnaissance(i).Month + Me.m_reconnaissance.ArrReconnaissance(i).Day)
            End If

        Next
         Me.cob_TimeType.Items.Add(Me.m_reconnaissance.ArrReconnaissance(Me.m_reconnaissance.ArrReconnaissance.Length - 1).Year + Me.m_reconnaissance.ArrReconnaissance(Me.m_reconnaissance.ArrReconnaissance.Length - 1).Month + Me.m_reconnaissance.ArrReconnaissance(Me.m_reconnaissance.ArrReconnaissance.Length - 1).Day)

         Me.cob_ParameterType.Text = Me.m_reconnaissance.ArrReconnaissance(0).Time
         Me.cob_TimeType.Text = Me.m_reconnaissance.ArrReconnaissance(0).Year + Me.m_reconnaissance.ArrReconnaissance(0).Month + Me.m_reconnaissance.ArrReconnaissance(0).Day
    End Sub
End Class